package bigdata.scala.spark.streaming.ycfx.util

import java.util

import bigdata.scala.spark.streaming.ycfx.model.UserStatus

object VoltageToHbUtil {
  def dataToMap(rowkey:String,t:UserStatus): util.HashMap[String,String] ={
    val dataMaps = new util.HashMap[String,String]()

    dataMaps.put("meter_id",t.meterId)
    dataMaps.put("meter_assetno",t.meterAssetno)

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("00")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u1)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u1)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u1)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("01")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u5)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u5)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u5)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("02")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u9)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u9)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u9)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("03")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u13)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u13)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u13)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("04")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u17)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u17)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u17)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("05")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u21)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u21)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u21)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("06")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u25)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u25)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u25)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("07")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u29)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u29)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u29)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("08")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u33)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u33)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u33)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("09")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u37)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u37)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u37)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("10")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u41)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u41)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u41)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("11")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u45)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u45)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u45)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("12")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u49)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u49)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u49)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("13")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u53)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u53)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u53)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("14")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u57)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u57)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u57)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("15")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u61)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u61)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u61)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("16")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u65)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u65)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u65)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("17")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u69)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u69)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u69)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("18")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u73)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u73)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u73)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("19")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u77)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u77)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u77)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("20")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u81)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u81)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u81)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("21")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u85)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u85)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u85)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("22")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u89)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u89)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u89)
      }
    }

    if (rowkey.substring(rowkey.length-2,rowkey.length).equalsIgnoreCase("23")){
      if (t.phase.equalsIgnoreCase("1")){
        //A相电压
        dataMaps.put("ua",t.u93)
      }else if(t.phase.equalsIgnoreCase("2")){
        //B相电压
        dataMaps.put("ub",t.u93)
      }else if(t.phase.equalsIgnoreCase("3")){
        //C相电压
        dataMaps.put("uc",t.u93)
      }
    }

    dataMaps
  }
}
